package top.korori.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import top.korori.common.bo.MediaVideoFormBo;
import top.korori.common.model.Result;
import top.korori.common.bo.MediaPicFormBo;
import top.korori.entity.res.SvMediaRes;
import top.korori.enums.SvMediaSourceEnum;
import top.korori.service.ISvMediaService;

/**
 * 媒体文件 前端控制器
 *
 * @author korori
 */
@Api(tags = "媒体文件")
@RestController
@RequestMapping("/sv/media")
public class SvMediaController {

    @Autowired
    private ISvMediaService svMediaService;

    @ApiOperation("通用图片上传")
    @PostMapping("/uploadPic")
    public Result<SvMediaRes> uploadPic(@RequestParam(required = false) MultipartFile file, MediaPicFormBo mediaFormBo){
        SvMediaRes svMediaRes = svMediaService.uploadPic(file,mediaFormBo, SvMediaSourceEnum.FRONT.getSource());
        return Result.ok(svMediaRes);
    }

    @ApiOperation("Base64图片上传")
    @PostMapping("/uploadBase64Pic")
    public Result<SvMediaRes> uploadBase64Pic(@RequestBody MediaPicFormBo mediaFormBo){
        SvMediaRes svMediaRes = svMediaService.uploadBase64Pic(mediaFormBo, SvMediaSourceEnum.FRONT.getSource());
        return Result.ok(svMediaRes);
    }

    @ApiOperation("通用视频上传")
    @PostMapping("/uploadVideo")
    public Result<SvMediaRes> uploadVideo(@RequestParam MultipartFile file, MediaVideoFormBo mediaFormBo){
        SvMediaRes svMediaRes = svMediaService.uploadVideo(file,mediaFormBo, SvMediaSourceEnum.FRONT.getSource());
        return Result.ok(svMediaRes);
    }

}














